'use strict';

const Sequelize = require('sequelize');
const sequelize = require('../plugins/db');

const Model = Sequelize.Model;
class Category extends Model {}

// 静态属性：主键字段名称
Category.pk = 'cid';
Category.init({
    cid: {
      type: Sequelize.INTEGER,
      autoIncrement: true,
      primaryKey: true,
      comment: '分类id'
    },
    pid: {
      type:  Sequelize.INTEGER,
      defaultValue: 0,
      comment: '父类pid'
    },
    name: {
      type: Sequelize.STRING,
      allowNull: false
    },
    english_name: Sequelize.STRING,
    intro: Sequelize.TEXT,
    images: Sequelize.TEXT,
    cover: Sequelize.STRING,
    redirect_url: Sequelize.STRING,
    redirect: {
        type: Sequelize.ENUM('yes', 'no'),
        allowNull: false,
        defaultValue: 'no'
    },
    status: {
        type: Sequelize.STRING,
        defaultValue: 'normal'
    },
    model: {
      type: Sequelize.STRING,
      defaultValue: 'common'
    },
    remark: {
      type: Sequelize.TEXT
    }
}, {
    sequelize,
    tableName: 'category',
    freezeTableName: true,
    timestamps: true
});
module.exports = Category;
